import 'dart:convert';

import 'package:flutter_test/flutter_test.dart';
import 'package:im_app/im/socket/dto/base/Req.dart';
import 'package:im_app/im/socket/dto/base/Resp.dart';
import 'package:im_app/im/socket/dto/business/Message.dart';
import 'package:im_app/im/socket/dto/business/PullData.dart';
import 'package:im_app/im/socket/dto/business/PullData2.dart';
import 'package:im_app/im/socket/dto/business/RpcData.dart';
import 'package:im_app/im/socket/dto/business/SendData.dart';

void main() {
  test("encode pull message", () {
    DepartmentInfoListReq departmentInfoListReq = new DepartmentInfoListReq();
    departmentInfoListReq.pageSize = 1000;
    RpcData rpcData2 = RpcData.data("pullDepartments", departmentInfoListReq, "123");
    String dataJson = jsonEncode(rpcData2.data);
    print("data json : $dataJson");
  });

  test("encode group", () {
    GroupInfoListReq groupInfoListReq = new GroupInfoListReq(GroupType.chat);
    groupInfoListReq.pageSize = 1000;
    RpcData rpcData2 = RpcData.data("pullGroups", groupInfoListReq, "123");
    String dataJson = jsonEncode(rpcData2.data);
    print("data json : $dataJson");
  });

  test("encode sensitiveReq", () {
    var sensitivePullReq = new SensitiveWordPullReq();
    sensitivePullReq.pageSize = 1000;
    RpcData rpcData2 = RpcData.data("pullSenstiveWords", sensitivePullReq, "123");
    String dataJson = jsonEncode(rpcData2.data);
    print("data json : $dataJson");
  });

  test("encode okListResp", () {
    var okListResp = new OkListResp(localSeqSet: ['1', '2'].toSet(), successDataTime: DateTime.now(), coder: 1);
    RpcData rpcData2 = RpcData.data("resp", okListResp, "123");
    String dataJson = jsonEncode(rpcData2.data);
    print("data json : $dataJson");
  });

  test("encode messageObject", () {
    var messageObject = MessageObject("test00100", "hello word", MessageType.Text);
    messageObject.status = MessageStatus.receive;
    RpcData rpcData2 = RpcData.data("resp", messageObject, "123");
    String dataJson = jsonEncode(rpcData2.data);
    print("data json : $dataJson");
  });

  test("encode messageObjectsReq", () {
    var messageObject = MessageObject("test00100", "hello word", MessageType.Text);
    messageObject.status = MessageStatus.receive;
    var messageObjectsReq = MessageObjectsReq(messageObjects: [messageObject]);
    RpcData rpcData2 = RpcData.data("resp", messageObjectsReq, "123");
    String dataJson = jsonEncode(rpcData2.data);
    print("data json : $dataJson");
  });

  test("encode okReq", () {
    var okReq = OkReq(coder: 0, otherInfo: '1213');
    RpcData rpcData2 = RpcData.data("okReq", okReq, "123");
    String dataJson = jsonEncode(rpcData2.data);
    print("data json : $dataJson");
  });

  test("encode  okListReq", () {
    var okListReq = OkListReq(coder: 0, otherInfo: '1213', localSeqSet: ['121', '222'].toSet());
    RpcData rpcData2 = RpcData.data("okListReq", okListReq, "123");
    String dataJson = jsonEncode(rpcData2.data);
    print("data json : $dataJson");
  });

  test("encode messageRed", () {
    var messageReadReq = MessageReadReq(messageIds: ['121', '222'].toList());
    RpcData rpcData2 = RpcData.data("MessageReadReq", messageReadReq, "123");
    String dataJson = jsonEncode(rpcData2.data);
    print("data json : $dataJson");
  });

  test("decode messageRed", () {
    var messageReadReq = MessageReadReq.fromJson({"createDateTime":"2024-06-25 15:32:58","localSeq":null,"messageIds":["121","222"]});
    String dataJson = jsonEncode(messageReadReq);
    print("data json : $dataJson");
  });

  test("decode dataChangeReq", () {
    var json = {"type":1,"subType":"g_ed_name","key":"ff143009-c4b8-5ff2-8e91-0800a4f32b23","value":"二曹战张飞666","createDateTime":"2024-09-02 17:15:53"};
    var dataChangeReq = DataChangeReq.fromJson(json);
    print("data json : $dataChangeReq");
  });
}